﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace QuanLiGiaiBongDa
{
    public class DBAccess
    {
        public DataSet ExecSQLDataSet(string sql)
        {
            DataSet ds = new DataSet();
            SqlConnection con = ConnectToDataBase.StartConnection();
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            da.Fill(ds);
            return ds;
        }
        public DataTable ExecSQLDataTable(string sql)
        {
            DataTable dt = new DataTable();
            SqlConnection con = ConnectToDataBase.StartConnection();
            SqlDataAdapter da = new SqlDataAdapter(sql,con);
            da.Fill(dt);
            return dt;
        }

        public int ExecNonQuery(string sql)
        {
            int res = 0;
            SqlConnection con = ConnectToDataBase.StartConnection();
            SqlCommand cmd = new SqlCommand(sql, con);
            con.Open();
            res = cmd.ExecuteNonQuery();
            con.Close();
            return res;
        }
        

    }
}
